package com.example.layui_project.enums;

/**
 * 使用枚举表述常量数据字典
 */
public enum ResultCode {
    SUCCESS(0, "success"), 
    SYSTEM_BUSY(-1,"系统繁忙"),
    VERIFYCODE_ERROR(101, "验证码错误"),
    USERINFO_ERROR(102, "账户名或者密码错误"),
    PERMISSION_ERROR(401, "您无权执行该操作!!!");
    private Integer code;

    private String info;

    private ResultCode(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public static ResultCode stateOf(int index) {
        for (ResultCode state : values()) {
            if (state.getCode().equals(index)) {
                return state;
            }
        }
        return null;
    }

}
